package com.cavy.platform.server.mapper;

import com.cavy.platform.server.domain.Project;
import com.cavy.platform.server.dto.ProjectCreateDto;
import com.cavy.platform.server.dto.ProjectDeleteDto;
import com.cavy.platform.server.dto.ProjectDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author 唐旭
 * @Date 2018/7/17
 */
@Mapper
public interface ProjectMapper {
    ProjectMapper INSTANCE = Mappers.getMapper(ProjectMapper.class);

    @Mapping(target = "workSpace.name", source = "workspace")
    Project convertTo(ProjectCreateDto dto);

    @Mapping(target = "workSpace.name", source = "workspace")
    Project convertTo(ProjectDeleteDto dto);

    @Mapping(target = "workSpace", source = "workSpace.name")
    ProjectDto convertToDto(Project item);

    @Mapping(target = "name", source = "item")
    @Mapping(target = "workSpace.name", source = "workSpace")
    Project convertTo(String item, String workSpace);
}
